<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Plural version of gettext</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.ngettext" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ngettext</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">ngettext</span> &mdash; <span class="dc-title">Plural version of gettext</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.ngettext-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ngettext</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$msgid1</code></span>
   , <span class="methodparam"><span class="type">string</span> <code class="parameter">$msgid2</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$n</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   The plural version of <span class="function"><a href="gettext.html" class="function">gettext()</a></span>.  Some languages 
   have more than one form for plural messages dependent on the count.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ngettext-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">msgid1</code></dt>

     <dd>

      <p class="para">
       The singular message ID.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">msgid2</code></dt>

     <dd>

      <p class="para">
       The plural message ID.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">n</code></dt>

     <dd>

      <p class="para">
       The number (e.g. item count) to determine the translation for the
       respective grammatical number.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ngettext-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns correct plural form of message identified by 
   <code class="parameter">msgid1</code> and <code class="parameter">msgid2</code>
   for count <code class="parameter">n</code>. 
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ngettext-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2888">
    <p><strong>Example #1 <span class="function"><strong>ngettext()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />setlocale</span><span style="color: #007700">(</span><span style="color: #0000BB">LC_ALL</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'cs_CZ'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #0000BB">ngettext</span><span style="color: #007700">(</span><span style="color: #DD0000">"%d&nbsp;window"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"%d&nbsp;windows"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;1&nbsp;okno<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #0000BB">ngettext</span><span style="color: #007700">(</span><span style="color: #DD0000">"%d&nbsp;window"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"%d&nbsp;windows"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;2&nbsp;okna<br /></span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #0000BB">ngettext</span><span style="color: #007700">(</span><span style="color: #DD0000">"%d&nbsp;window"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"%d&nbsp;windows"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">),&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;5&nbsp;oken<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>